#include <vector>
#include <iostream>

using namespace std;

void print(vector<int> number){
    cout << "_vec_: ";
    for(auto & elm : number ){
        cout << elm << " ";
    }
    cout << endl;
}
void display(vector<int> & number){
    cout << "size = " << number.size() << endl;
    cout << "capacity = " << number.capacity() << endl;

}
void test(){
    vector<int> vec = {1,2,3};
    display(vec);
    print(vec);
    
    cout << "=================" << endl;
    cout << "扩增元素" << endl;
    vec.resize(5);
    display(vec);
    print(vec);
    // tips:
    // 开始时vector的capacity是3
    // 若是此时扩增的元素大小小于两倍的capacity()
    // (小于两倍的容量扩增的值)
    // 那就会进行两倍扩增
    // 若是大于两倍的扩增就会进行按大小扩增
    // 比如这里若是vec.resize(10);
    // 那么打印出来的capacity就是10

    cout << "+++++=+++++++++++" << endl;
    cout << "缩减元素" << endl;
    vec.resize(2);
    //缩减元素不会将vector的容量减小
    display(vec);
    print(vec);

}

int main(int atgc, char * argv[])
{
    test();
    return 0;
}

